package com.samuel.demo.controller;/*
 * @date:2017/11/20
 * @time: 10:23
 * @author:zhaoyang
 * @desc:前端控制器，demo
 **/

import com.samuel.demo.service.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BookController {

    @Autowired
    private BookRepository bookRepository;

    @GetMapping(value = "/")
    public String index(){
        return "hello,world!";
    }


    @GetMapping(value = "/insert")
    public String addBooks(Integer id, String name, String desc){

       if(bookRepository.inserBook(id,name,desc).booleanValue()) {
           return "add Book Success!";
       } else {
           return "insert fails";
       }
    }



}
